package com.tensquare.user.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.tensquare.user.pojo.User;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * 数据访问接口
 * @author Administrator
 *
 */
public interface UserDao extends JpaRepository<User,String>,JpaSpecificationExecutor<User>{
	public User findByMobile(String mobile);

	/**
	 * 根据当前用户id，更新粉丝数
	 * @param userid
	 * @param x
	 */
	@Modifying
	@Query(nativeQuery = true,value = "update tb_user set fanscount=fanscount + ? where id =?")
	public void incFanscount(int x,String userid);

	/**
	 * 更新关注数
	 * @param x
	 * @param userid
	 */
	@Modifying
	@Query(nativeQuery = true,value = "update tb_user set followcount=followcount + ? where id =?")
	public void incFollowcount(int x,String userid);
}
